package com.soul.soulcommon.result;
import lombok.Data;
@Data
public class Result <T>{
    private static final int SUCCESS_CODE = 200;
    private static final int ERROR_CODE = 400;
    private Integer code;
    private String msg;
    private T data;
    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static <T> Result<T> success(T data){
        return new Result<>(SUCCESS_CODE, "success", data);
    }

    public static <T> Result<T> success(String msg,T data){
        return new Result<>(SUCCESS_CODE, msg, data);
    }
    public static <T> Result<T> success(){
        return new Result<>(SUCCESS_CODE, "success", null);
    }
    public static <T> Result<T> error(Integer code,String msg,T data){
        return new Result<>(code, msg, data);
    }
    public static <T> Result<T> success(String msg){
        return new Result<>(SUCCESS_CODE, msg, null);
    }
    public static <T> Result<T> error(){
        return new Result<>(ERROR_CODE, "error", null);
    }
    public static <T> Result<T> error(String msg){
        return new Result<>(ERROR_CODE, msg, null);
    }
    public static <T> Result<T> error(String msg,T data){
        return new Result<>(ERROR_CODE, msg, data);
    }
    public static <T> Result<T> error(Integer code,String msg){
        return new Result<>(code, msg, null);
    }

}
